<?php
require_once "KLogger.class.php";

// EMERG  = 0;  // Emergency: system is unusable
// ALERT  = 1;  // Alert: action must be taken immediately
// CRIT   = 2;  // Critical: critical conditions
// ERR    = 3;  // Error: error conditions
// WARN   = 4;  // Warning: warning conditions
// NOTICE = 5;  // Notice: normal but significant condition
// INFO   = 6;  // Informational: informational messages
// DEBUG  = 7;  // Debug: debug messages
	
class Logger {
   // 是否记录log
   public static $logging = true;
   // log文件夹位置
   public static $log_directory = "logs";
   // log级别
   public static $log_level = KLogger::INFO;
   // logger对象
   public static $logger;
   
   public static function getInstance() {
       if (empty(self::$logger)) {
           self::$logger = KLogger::instance(self::$log_directory, self::$log_level);
       }
	   return self::$logger;
   }

   public static function debug($content) {
	   if (self::$logging) {
	       self::getInstance()->logDebug($content);
	   }
   }

   public static function info($content) {
	   if (self::$logging) {
	       self::getInstance()->logInfo($content);
	   }
   }

   public static function notice($content) {
	   if (self::$logging) {
	       self::getInstance()->logNotice($content);
	   }
   }

   public static function warn($content) {
	   if (self::$logging) {
	       self::getInstance()->logWarn($content);
	   }
   }

   public static function error($content) {
	   if (self::$logging) {
	       self::getInstance()->logError($content);
	   }
   }

}
